home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1995.rar / 1995 / MAY / Dr9505 / search.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-07  |  957b  |  45 lines

  1. unit Search;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Grids, DBGrids, DB, DBTables, ExtCtrls;
  8.  
  9. type
  10.   TLocate_Example = class(TForm)
  11.     Table1: TTable;
  12.     DataSource1: TDataSource;
  13.     DBGrid1: TDBGrid;
  14.     Edit1: TEdit;
  15.     Label1: TLabel;
  16.     Button1: TButton;
  17.     Label2: TLabel;
  18.     Shape1: TShape;
  19.     Image1: TImage;
  20.     Label3: TLabel;
  21.     procedure Button1Click(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.   end;
  27.  
  28. var
  29.   Locate_Example: TLocate_Example;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure TLocate_Example.Button1Click(Sender: TObject);
  36. begin
  37.   Table1.SetKey;   {Put Table1 into search mode}
  38.   Table1.Fields[0].AsString := Edit1.Text;
  39.   if not Table1.GoToKey then   {Attempt search}
  40.     MessageDlg(Edit1.Text+' could not be found.',
  41.     mtError,[mbOK],0);
  42. end;
  43.  
  44. end.
  45.